<!DOCTYPE html>
<html>
<head>
  <title>Accessible boundaries when page is zoomed</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>
  <script type="application/javascript"
          src="../layout.js"></script>
  <script type="application/javascript"
          src="../browser.js"></script>

  <script type="application/javascript">
    //gA11yEventDumpToConsole = true;
    //enableLogging("tree,verbose");
    function doPreTest()
    {
      var tabDocument = currentTabDocument();
      var imgMap = tabDocument.getElementById("imgmap");
      waitForImageMap(imgMap, doTest);
    }

    function doTest()
    {
      // Bug 746176: Failure of this whole test file on OS X.
      if (MAC) {
        todo(false, "Fix bug 746176 on Mac");
        closeBrowserWindow();
        SimpleTest.finish();
        return;
      }

      var tabDocument = currentTabDocument();
      var p1 = tabDocument.getElementById("p1");
      var p2 = tabDocument.getElementById("p2");

      var imgMap = tabDocument.getElementById("imgmap");
      var imgMapAcc = getAccessible(imgMap);
      var area = imgMapAcc.firstChild;

      testBounds(p1);
      testBounds(p2);
      testBounds(area);

      zoomDocument(tabDocument, 2.0);

      testBounds(p1);
      testBounds(p2);
      testBounds(area);

      closeBrowserWindow();
      SimpleTest.finish();
    }

    var url = "data:text/html,<html><body>";
    url += "<p id='p1'>para 1</p><p id='p2'>para 2</p>";
    url += "<map name='atoz_map' id='map'>";
    url += "  <area id='area1' href='http%3A%2F%2Fmozilla.org'";
    url += "        coords=17,0,30,14' alt='mozilla.org' shape='rect'>";
    url += "</map>";
    url += "<img id='imgmap' width='447' height='15'";
    url += "     usemap='%23atoz_map'";
    url += "     src='chrome%3A%2F%2Fmochitests%2Fcontent%2Fa11y%2Faccessible%2Fletters.gif'>";
    url += "</body></html>";

    SimpleTest.waitForExplicitFinish();
    openBrowserWindow(doPreTest,
                      url,
                      { left: 0, top: 0, width: 600, height: 600 });
  </script>

</head>
<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=650241"
     title="Location returned by accessibles incorrect when page zoomed">
    Mozilla Bug 650241
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>
</body>
</html>
